<template>
  <div class="product-add page-container">
    <div class="page-header">
      <div class="header-left">
        <el-button link @click="goBack" class="back-btn">
          <svg class="back-icon" viewBox="0 0 24 24" fill="currentColor">
            <path
              d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"
            />
          </svg>
          返回
        </el-button>
      </div>
      <div class="header-content">
        <h1 class="page-title">新增商品</h1>
        <p class="page-subtitle">添加新的商品信息，支持SPU和SKU的完整配置</p>
      </div>
    </div>

    <div class="content-card">
      <el-form
        ref="formRef"
        :model="form"
        :rules="rules"
        label-width="100px"
        class="product-form"
      >
        <!-- SPU基本信息 -->
        <div class="form-section">
          <h3 class="section-title">商品基本信息</h3>
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="商品名称" prop="spuName">
                <el-input v-model="form.spuName" placeholder="请输入商品名称" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="商品标语" prop="subTitle">
                <el-input
                  v-model="form.subTitle"
                  placeholder="通过简洁有力的语言或创意表达（如双关语、押韵等），快速抓住消费者眼球。"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="商品分类" prop="categoryId">
                <el-tree-select
                  v-model="form.categoryId"
                  :data="categoryOptions"
                  :props="{ label: 'name', value: 'id', children: 'children' }"
                  placeholder="请选择商品分类"
                  clearable
                  class="tree-select"
                  @change="handleCategoryChange"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="商品标签" prop="labelId">
                <el-select
                  v-model="form.labelId"
                  placeholder="请选择商品标签"
                  clearable
                  class="select-input"
                >
                  <el-option
                    v-for="label in labelList"
                    :key="label.id"
                    :label="label.labelName"
                    :value="label.id"
                  />
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-form-item
            label="商品图集"
            prop="spuImagesList"
            :rules="[{ validator: validateMainImages, trigger: 'change' }]"
          >
            <div class="main-image-upload-container">
              <div
                v-for="(image, index) in form.spuImagesList"
                :key="index"
                class="main-image-item"
              >
                <img :src="image" class="main-image-preview" />
                <div class="image-actions">
                  <el-button
                    type="danger"
                    size="small"
                    @click="removeMainImage(index)"
                    circle
                  >
                    <el-icon><Delete /></el-icon>
                  </el-button>
                </div>
              </div>
              <div
                v-if="form.spuImagesList.length < 9"
                class="main-image-upload"
              >
                <ImageCropperUpload
                  :width="500"
                  :height="400"
                  :fixed-number="[5, 4]"
                  :show-preview="false"
                  @imgupload="handleMainImageUpload"
                />
                <div class="upload-tip">商品图集比例5:4，最多上传9张</div>
              </div>
            </div>
          </el-form-item>

          <el-form-item label="商品描述" prop="description">
            <el-input
              v-model="form.description"
              type="textarea"
              :rows="4"
              placeholder="请输入商品描述"
            />
          </el-form-item>
        </div>

        <!-- SKU列表 -->
        <div class="form-section" v-if="form.categoryId">
          <div class="section-header">
            <h3 class="section-title">SKU规格管理</h3>
            <el-button type="primary" @click="addSku" size="small">
              <el-icon><Plus /></el-icon>
              添加SKU
            </el-button>
          </div>

          <div
            v-if="form.productSkus && form.productSkus.length > 0"
            class="sku-list"
          >
            <div
              v-for="(sku, index) in form.productSkus"
              :key="index"
              class="sku-item"
            >
              <div class="sku-header">
                <h4>SKU {{ index + 1 }}</h4>
                <el-button
                  type="danger"
                  size="small"
                  @click="removeSku(index)"
                  class="remove-btn"
                >
                  删除
                </el-button>
              </div>

              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item
                    :label="`销售价`"
                    :prop="`productSkus.${index}.price`"
                    :rules="[
                      {
                        required: true,
                        message: '请输入销售价',
                        trigger: 'blur',
                      },
                    ]"
                  >
                    <el-input-number
                      v-model="sku.price"
                      :precision="2"
                      :min="0"
                      placeholder="请输入销售价"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    :label="`市场价`"
                    :prop="`productSkus.${index}.marketPrice`"
                    :rules="[
                      {
                        required: true,
                        message: '请输入市场价',
                        trigger: 'blur',
                      },
                    ]"
                  >
                    <el-input-number
                      v-model="sku.marketPrice"
                      :precision="2"
                      :min="0"
                      placeholder="请输入市场价"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    :label="`成本价`"
                    :prop="`productSkus.${index}.costPrice`"
                  >
                    <el-input-number
                      v-model="sku.costPrice"
                      :precision="2"
                      :min="0"
                      placeholder="请输入成本价"
                    />
                  </el-form-item>
                </el-col>
              </el-row>

              <el-row :gutter="20">
                <el-col :span="8">
                  <el-form-item
                    :label="`库存`"
                    :prop="`productSkus.${index}.stock`"
                    :rules="[
                      {
                        required: true,
                        message: '请输入库存',
                        trigger: 'blur',
                      },
                    ]"
                  >
                    <el-input-number
                      v-model="sku.stock"
                      :min="0"
                      placeholder="请输入库存"
                    />
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item
                    :label="`预警库存`"
                    :prop="`productSkus.${index}.warnStock`"
                  >
                    <el-input-number
                      v-model="sku.warnStock"
                      :min="0"
                      placeholder="请输入预警库存"
                    />
                  </el-form-item>
                </el-col>
              </el-row>

              <el-form-item
                :label="`SKU图片`"
                :prop="`productSkus.${index}.image`"
                :rules="[
                  {
                    required: true,
                    message: '请上传SKU图片',
                    trigger: 'change',
                  },
                ]"
                style="margin-top: 20px"
              >
                <div class="sku-image-upload-container">
                  <div v-if="sku.image" class="sku-image-preview">
                    <img :src="sku.image" class="sku-image" />
                    <div class="image-actions">
                      <el-button
                        type="danger"
                        size="small"
                        @click="removeSkuImage(index)"
                        circle
                      >
                        <el-icon><Delete /></el-icon>
                      </el-button>
                    </div>
                  </div>
                  <div v-else class="sku-image-upload">
                    <ImageCropperUpload
                      :width="100"
                      :height="100"
                      :fixed-number="[1, 1]"
                      @imgupload="
                        (imageUrl) => handleSkuImageUpload(imageUrl, index)
                      "
                    />
                  </div>
                </div>
              </el-form-item>

              <!-- 规格属性 -->
              <div v-if="categoryAttributes.length > 0" class="specs-section">
                <h5>规格属性</h5>
                <el-row :gutter="20">
                  <el-col
                    v-for="attribute in categoryAttributes"
                    :key="attribute.id"
                    :span="8"
                  >
                    <el-form-item
                      :label="attribute.name"
                      :required="attribute.isRequired === 1"
                    >
                      <el-input
                        v-if="attribute.inputType === 1"
                        :model-value="getSkuSpecs(sku, attribute.name)"
                        :placeholder="`请输入${attribute.name}`"
                        @input="
                          (value: any) => setSkuSpecs(sku, attribute.name, value)
                        "
                      />
                      <el-select
                        v-else-if="attribute.inputType === 2"
                        :model-value="getSkuSpecs(sku, attribute.name)"
                        :placeholder="`请选择${attribute.name}`"
                        @change="
                          (value: any) => setSkuSpecs(sku, attribute.name, value)
                        "
                      >
                        <el-option
                          v-for="value in attribute.selectedValuesList"
                          :key="value"
                          :label="value"
                          :value="value"
                        />
                      </el-select>
                      <el-checkbox-group
                        v-else-if="attribute.inputType === 3"
                        :model-value="getSkuSpecsArray(sku, attribute.name)"
                        @change="
                          (value: any) => setSkuSpecs(sku, attribute.name, value)
                        "
                      >
                        <el-checkbox
                          v-for="value in attribute.selectedValuesList"
                          :key="value"
                          :label="value"
                        >
                          {{ value }}
                        </el-checkbox>
                      </el-checkbox-group>
                    </el-form-item>
                  </el-col>
                </el-row>
              </div>
            </div>
          </div>

          <div v-else class="no-sku">
            <el-empty description="请先选择商品分类，然后添加SKU" />
          </div>
        </div>
      </el-form>
    </div>
    <div class="page-footer">
      <div class="footer-content">
        <el-button @click="goBack" size="large">取消</el-button>
        <el-button
          type="primary"
          @click="saveProduct"
          :loading="saving"
          size="large"
        >
          保存商品
        </el-button>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted, computed } from "vue";
import { useRouter } from "vue-router";
import { ElMessage } from "element-plus";
import { Plus, Delete } from "@element-plus/icons-vue";
import { postWithAuth, getWithAuth } from "@/utils/request";
import ImageCropperUpload from "@/components/ImageCropperUpload.vue";

// 类型定义
interface ProductSku {
  id?: string;
  skuCode: string;
  spuId: string | number;
  specs: string | Record<string, any>;
  price: number;
  marketPrice: number;
  costPrice: number;
  stock: number;
  warnStock: number;
  image: string;
  status: number;
}

interface CategoryDTO {
  id: string;
  name: string;
  level: number;
  children?: CategoryDTO[];
}

interface LabelDTO {
  id: string;
  labelName: string;
  status: number;
}

interface AttributeDTO {
  id: string;
  name: string;
  type: number;
  inputType: number;
  values: string;
  valueList: string[];
  selectedValues: string;
  selectedValuesList: string[];
  isRequired: number;
}

// 响应式数据
const router = useRouter();
const saving = ref(false);
const formRef = ref();

// 分类和标签
const categoryList = ref<CategoryDTO[]>([]);
const labelList = ref<LabelDTO[]>([]);
const categoryAttributes = ref<AttributeDTO[]>([]);

// SPU表单数据
const form = reactive({
  spuName: "",
  subTitle: "",
  categoryId: "",
  labelId: "",
  spuImagesList: [] as string[], // 商品图集url数组
  description: "",
  productSkus: [] as ProductSku[],
});

// 分类选项
const categoryOptions = computed(() => {
  const options: CategoryDTO[] = [];
  const addCategories = (categories: CategoryDTO[]) => {
    categories.forEach((category) => {
      if (category.level === 2) {
        options.push(category);
      }
      if (category.children) {
        addCategories(category.children);
      }
    });
  };
  addCategories(categoryList.value);
  return options;
});

// 表单验证规则
const rules = {
  spuName: [{ required: true, message: "请输入商品名称", trigger: "blur" }],
  categoryId: [
    { required: true, message: "请选择商品分类", trigger: "change" },
  ],
  spuImagesList: [
    {
      type: "array",
      required: true,
      message: "请上传商品图集",
      trigger: "change",
    },
  ],
  detailImageList: [
    {
      type: "array",
      required: true,
      message: "请上传详情图",
      trigger: "change",
    },
  ],
};

// 获取分类列表
const fetchCategoryList = async () => {
  try {
    const response = await postWithAuth("/internal/category/pageListByName", {
      name: "",
      isShow: 1,
      pageIndex: 1,
      pageSize: 1000,
    });

    if (response.code === 0) {
      categoryList.value = response.data.list;
    } else {
      ElMessage.error(response.message || "获取分类列表失败");
    }
  } catch (error) {
    console.error("获取分类列表失败:", error);
    ElMessage.error("获取分类列表失败");
  }
};

// 获取标签列表
const fetchLabelList = async () => {
  try {
    const response = await getWithAuth(
      "/internal/label/list?labelName=&status=1"
    );

    if (response.code === 0) {
      labelList.value = response.data;
    } else {
      ElMessage.error(response.message || "获取标签列表失败");
    }
  } catch (error) {
    console.error("获取标签列表失败:", error);
    ElMessage.error("获取标签列表失败");
  }
};

// 获取分类属性
const fetchCategoryAttributes = async (categoryId: string | number) => {
  try {
    const response = await getWithAuth(
      `/internal/category/selectById?id=${categoryId}`
    );

    if (response.code === 0 && response.data.attributeDTOS) {
      categoryAttributes.value = response.data.attributeDTOS;
    } else {
      categoryAttributes.value = [];
    }
  } catch (error) {
    console.error("获取分类属性失败:", error);
    categoryAttributes.value = [];
  }
};

// 返回上一页
const goBack = () => {
  router.back();
};

// 保存商品
const saveProduct = async () => {
  if (!formRef.value) return;

  try {
    await formRef.value.validate();
    saving.value = true;

    // 确保productSkus存在
    const requestData = {
      ...form,
      productSkus: form.productSkus || [],
    };

    const response = await postWithAuth("/internal/product/add", requestData);

    if (response.code === 0) {
      ElMessage.success("新增成功");
      router.push("/products");
    } else {
      ElMessage.error(response.message || "新增失败");
    }
  } catch (error) {
    console.error("保存商品失败:", error);
    ElMessage.error("保存失败");
  } finally {
    saving.value = false;
  }
};

// 分类变化处理
const handleCategoryChange = async (categoryId: string | number) => {
  if (categoryId) {
    await fetchCategoryAttributes(categoryId);
  } else {
    categoryAttributes.value = [];
  }
};

// 图片上传相关函数

// SKU管理函数
const addSku = () => {
  if (!form.productSkus) {
    form.productSkus = [];
  }

  const newSku: ProductSku = {
    skuCode: "",
    spuId: "",
    specs: "{}",
    price: 0,
    marketPrice: 0,
    costPrice: 0,
    stock: 0,
    warnStock: 0,
    image: "",
    status: 1,
  };

  form.productSkus.push(newSku);
};

const removeSku = (index: number) => {
  form.productSkus!.splice(index, 1);
};

// SKU规格属性处理函数
const getSkuSpecs = (sku: ProductSku, key: string): string => {
  try {
    const specs =
      typeof sku.specs === "string"
        ? JSON.parse(sku.specs)
        : (sku.specs as Record<string, any>);
    return specs[key] || "";
  } catch {
    return "";
  }
};

const setSkuSpecs = (sku: ProductSku, key: string, value: any) => {
  try {
    const specs =
      typeof sku.specs === "string"
        ? JSON.parse(sku.specs)
        : (sku.specs as Record<string, any>);
    specs[key] = value;
    sku.specs = JSON.stringify(specs);
  } catch {
    sku.specs = JSON.stringify({ [key]: value });
  }
};

const getSkuSpecsArray = (sku: ProductSku, key: string): string[] => {
  try {
    const specs =
      typeof sku.specs === "string"
        ? JSON.parse(sku.specs)
        : (sku.specs as Record<string, any>);
    const value = specs[key];
    return Array.isArray(value) ? value : [];
  } catch {
    return [];
  }
};

// 校验函数
const validateMainImages = (_: any, value: string[], callback: any) => {
  if (!value || value.length === 0) {
    callback(new Error("请上传商品图集"));
  } else if (value.length > 9) {
    callback(new Error("商品图集最多9张"));
  } else {
    callback();
  }
};

// 图片上传相关函数

// 新的图片裁剪上传处理方法
const handleMainImageUpload = (imageUrl: string | null) => {
  if (imageUrl) {
    form.spuImagesList.push(imageUrl);
    ElMessage.success("商品图集上传成功");
  }
};

const handleSkuImageUpload = (imageUrl: string | null, index: number) => {
  if (imageUrl) {
    form.productSkus![index].image = imageUrl;
    ElMessage.success("SKU图片上传成功");
  }
};

// 图片删除方法
const removeMainImage = (index: number) => {
  form.spuImagesList.splice(index, 1);
  ElMessage.success("商品图集已删除");
};

const removeSkuImage = (index: number) => {
  form.productSkus![index].image = "";
  ElMessage.success("SKU图片已删除");
};

// 页面加载时获取数据
onMounted(() => {
  fetchCategoryList();
  fetchLabelList();
});
</script>

<style scoped>
.product-add {
  padding: 20px;
  background-color: #f5f7fa;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: flex-start;
  margin-bottom: 24px;
  /* background: white;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); */
}

.header-left {
  margin-right: 20px;
  padding-top: 4px;
}

.header-content {
  flex: 1;
}

.header-content {
  flex: 1;
}

.page-title {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: #303133;
}

.page-subtitle {
  margin: 0;
  color: #909399;
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

.content-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.product-form {
  padding: 20px;
}

.tree-select {
  width: 100%;
}

.select-input {
  width: 100%;
}

/* 表单区域样式 */
.form-section {
  margin-bottom: 30px;
  padding: 20px;
  border: 1px solid #e4e7ed;
  border-radius: 8px;
  background-color: #fafafa;
}

.section-title {
  margin: 0 0 20px 0;
  font-size: 16px;
  font-weight: 600;
  color: #303133;
  border-bottom: 2px solid #409eff;
  padding-bottom: 8px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.sku-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sku-item {
  padding: 20px;
  border: 1px solid #dcdfe6;
  border-radius: 8px;
  background-color: white;
}

.sku-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ebeef5;
}

.sku-header h4 {
  margin: 0;
  color: #303133;
  font-size: 14px;
  font-weight: 600;
}

.remove-btn {
  margin-left: 10px;
}

.specs-section {
  margin-top: 30px;
  padding: 16px;
  background-color: #f5f7fa;
  border-radius: 6px;
}

.specs-section h5 {
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 600;
  color: #606266;
}

.no-sku {
  text-align: center;
  padding: 40px 0;
}

/* 图片上传样式 */
.image-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  width: 120px;
  height: 120px;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: #fafafa;
}

.image-upload:hover {
  border-color: #409eff;
}

.uploaded-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-icon {
  font-size: 28px;
  color: #8c939d;
}

/* 新的图片上传样式 */
.main-image-upload-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.main-image-item {
  position: relative;
  width: 200px;
  height: 160px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.main-image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.main-image-upload {
  width: 200px;
  height: 160px;
  border: 2px dashed #d9d9d9;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}

.detail-image-upload-container {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.detail-image-item {
  position: relative;
  width: 200px;
  height: 160px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.detail-image-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.detail-image-upload {
  width: 200px;
  height: 160px;
  border: 2px dashed #d9d9d9;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}

.sku-image-upload-container {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 0;
  overflow: visible;
}

.sku-image-preview {
  position: relative;
  width: 100px;
  height: 100px;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
}

.sku-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sku-image-upload {
  width: 100px;
  height: 100px;
  border: 2px dashed #d9d9d9;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fafafa;
}

.image-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}

.main-image-item:hover .image-actions,
.detail-image-item:hover .image-actions,
.sku-image-preview:hover .image-actions {
  opacity: 1;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 500;
}

.back-btn:hover {
  color: #409eff;
  background-color: #f0f9ff;
}

.back-icon {
  width: 18px;
  height: 18px;
}

.page-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid #e4e7ed;
  padding: 16px 24px;
  z-index: 100;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.footer-content {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}

.product-add {
  padding-bottom: 80px;
}

.upload-tip {
  margin-top: 8px;
  font-size: 12px;
  color: #909399;
  line-height: 1.4;
}

/* 美化 SKU 图片上传占位符样式 */
:deep(.sku-image-upload-container) {
  /* 确保容器不会向上溢出 */
  position: relative;
  z-index: auto;
}

:deep(.sku-image-upload-container .image-cropper-upload) {
  /* 限制上传组件的边界 */
  display: inline-block;
  vertical-align: top;
}

:deep(.sku-image-upload-container .image-cropper-upload .upload-placeholder) {
  border: 2px dashed #409eff;
  border-radius: 12px;
  background: linear-gradient(135deg, #f6f8fb 0%, #e8f4fd 100%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(64, 158, 255, 0.08);
  position: relative;
  overflow: hidden;
  /* 确保不会超出容器边界 */
  max-width: 100%;
  max-height: 100%;
}

:deep(
    .sku-image-upload-container
      .image-cropper-upload
      .upload-placeholder::before
  ) {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle at center,
    rgba(64, 158, 255, 0.1) 0%,
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: -1;
  pointer-events: none;
}

:deep(
    .sku-image-upload-container .image-cropper-upload .upload-placeholder:hover
  ) {
  border-color: #409eff;
  background: linear-gradient(135deg, #e8f4fd 0%, #d4edff 100%);
  box-shadow: 0 4px 16px rgba(64, 158, 255, 0.2);
  /* 移除 translateY，避免影响上方元素 */
}

:deep(
    .sku-image-upload-container
      .image-cropper-upload
      .upload-placeholder:hover::before
  ) {
  opacity: 1;
}

:deep(
    .sku-image-upload-container
      .image-cropper-upload
      .upload-placeholder
      .upload-icon
  ) {
  font-size: 32px;
  color: #409eff;
  margin-bottom: 10px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

:deep(
    .sku-image-upload-container
      .image-cropper-upload
      .upload-placeholder:hover
      .upload-icon
  ) {
  color: #66b1ff;
  transform: scale(1.1);
}

:deep(
    .sku-image-upload-container
      .image-cropper-upload
      .upload-placeholder
      .upload-text
  ) {
  font-size: 14px;
  font-weight: 500;
  color: #409eff;
  margin-bottom: 6px;
  transition: all 0.3s ease;
  position: relative;
  z-index: 1;
}

:deep(
    .sku-image-upload-container
      .image-cropper-upload
      .upload-placeholder:hover
      .upload-text
  ) {
  color: #66b1ff;
}

:deep(
    .sku-image-upload-container
      .image-cropper-upload
      .upload-placeholder
      .upload-hint
  ) {
  font-size: 11px;
  color: #909399;
  position: relative;
  z-index: 1;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 16px;
    align-items: stretch;
  }

  .header-actions {
    justify-content: center;
  }

  .form-section {
    padding: 16px;
  }

  .sku-item {
    padding: 16px;
  }
}
</style>
